﻿@model PhoneBilling.Models.Report8ResultModel
@{
    ViewBag.Title = "长途统计";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnReturn").ligerButton(
        {
            click: function () {
                history.go(-1); //后退1页  
            }
        });
        $("#btnImport").ligerButton(
        {
            click: function () {
                $("form").submit();
            }
        });
    });
    
</script>
@using (Html.BeginForm("Report8", "Statistics"))
{
    @Html.HiddenFor(m => m.SelectItem)
    @Html.HiddenFor(m => m.开始日期)
    @Html.HiddenFor(m => m.结束日期)
    @Html.Hidden("IsExport", true)
    <input type="button" id="btnReturn" value="返回" />
    <input type="button" id="btnImport" value="导出Excel" />
@*    <input type="button" value="返回" onclick="back()"/>  
    <input type="submit" value="导出Excel"/>  *@
    @*<div>
        @{
    var grid = new WebGrid(source: Model.List, canPage: false);
        }
        @grid.GetHtml(
            alternatingRowStyle: "bg",
            columns: grid.Columns
            (
                    grid.Column("部门", "部门"),
                      grid.Column("分组", "分组"),
                        grid.Column("分机号码", "分机号码"),
                         grid.Column("国内时长", "国内时长"),
                        grid.Column("国内话费", "国内话费"),
                         grid.Column("国际时长", "国际时长"),
                         grid.Column("国际话费", "国际话费"),
                         grid.Column("总话费", "总话费")
            )
        )
    </div>*@
}
@{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.AppendLine(string.Format("var data={{Total:{0},",Model.List.Count));
    sb.AppendLine("Rows:[");
    for(int i =0;i < Model.List.Count;i++)
    {
        var item = Model.List[i];
        if(i == 0)
        {
            sb.Append("{");
        }
        else
        {
            sb.Append(",{");
        }
        sb.Append(string.Format("部门:'{0}',", item.部门));

        sb.Append(string.Format("分组:'{0}',", item.分组));
        sb.Append(string.Format("分机号码:'{0}',", item.分机号码));
        sb.Append(string.Format("国内时长:'{0}',", item.国内时长));
        sb.Append(string.Format("国内话费:'{0}',", item.国内话费));
        sb.Append(string.Format("国际时长:'{0}',", item.国际时长));
        sb.Append(string.Format("国际话费:'{0}',", item.国际话费));
        sb.Append(string.Format("总话费:'{0}'", item.总话费));
        sb.Append("}");
    }
    sb.AppendLine("]};");
    string data = sb.ToString();
}
<script type="text/javascript">
    @Html.Raw(data)
    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '部门', name: '部门',width:80},
                { display: '分组', name: '分组',width:80},
                { display: '分机号码', name: '分机号码',width:80},
                { display: '国内时长', name: '国内时长',width:140,totalSummary:                    {render: function (suminf, column, cell){                            return '<div>国内总时长:' + suminf.max + '</div>';                        }}},
                { display: '国内话费', name: '国内话费',width:140,totalSummary:                    {render: function (suminf, column, cell){                            return '<div>国内总话费:' + suminf.max + '</div>';                        }}},
                { display: '国际时长', name: '国际时长',width:140,totalSummary:                    {render: function (suminf, column, cell){                            return '<div>国际总时长:' + suminf.max + '</div>';                        }}},
                { display: '国际话费', name: '国际话费',width:140,totalSummary:                    {render: function (suminf, column, cell){                            return '<div>国际总话费:' + suminf.max + '</div>';                        }}},
                { display: '总话费', name: '总话费',width:140,totalSummary:                    {render: function (suminf, column, cell){                            return '<div>总话费:' + suminf.max + '</div>';                        }}}],
                isScroll: false, data: data,pageSize:30,alternatingRow:true
        }
        );resetGridHeight(grid);
        $(window).resize(function () {
                resetGridHeight(grid);
            });
    });</script>
    <div id="maingrid"></div>